home *** CD-ROM | disk | FTP | other *** search
/ Technotools / Technotools (Chestnut CD-ROM)(1993).ISO / lang_c / 13h_kit / keyboard.doc < prev    next >
Text File  |  1991-07-04  |  6KB  |  144 lines

  1. >>>KEYBOARD.DOC
  2.  
  3. A. Copyright Information
  4.  
  5. Keyboard.Hpp and Keyboard.Cpp along with this document file are copyright
  6. 1991 by the Gamers Programming Workshop, GAMERS forum, Compuserve (GO GAMERS,
  7. section 11). The code and related document are free for use, distribution,
  8. and modification, provided the following conditions are met:
  9.  
  10.     1. no commercial use of this source code or documents is permitted.
  11.     2. no fee may be charged beyond disk duplication cost for any of this
  12.        material.
  13.     3. If the code is upgraded or modified a copy of the modification must
  14.        be uploaded to section 11 of the GAMERS forum on Compuserve. All
  15.        modifications must be documented and the author's name included in
  16.        the source code header block, and the subsequent file package must
  17.        include all the original doc files as well as any additions. If you
  18.        modify or add functions please update the function list below.
  19.  
  20.  
  21. B. Description
  22.  
  23. Keyboard.cpp and Keyboard.hpp provide a flexible low level interface to the
  24. keyboard, which is used in this toolkit primarily by the font class read
  25. functions. It is not an event trapping system, but rather a low level key-
  26. board interface. For the purposes of the mode 13 toolkit if you prefer to
  27. use your own keyboard routines you will only have to modify the font::
  28. readstr() method, which calls getfilteredkey() (described below).
  29.  
  30. C. Function interface
  31.  
  32. *****************************************************************************
  33.  
  34. void getkey(char *key, extnd *scan);
  35.  
  36. getkey() returns the ascii and extended scan codes for the next key in the
  37. keyboard buffer. It calls interrupt 0x16, function 0x10, which will wait for
  38. a key if none has been pressed. Test with kbhit() if you don't the program
  39. to idle here. The ascii code is returned as an unsigned char, and the exten-
  40. ded code, if any, is returned as an enumerated type extnd (see definition
  41. below).
  42.  
  43. *****************************************************************************
  44.  
  45. boolean getfilteredkey(char mask, char *key, extnd *scan);
  46.  
  47. getfilteredkey() operates exactly as getkey() with one important difference.
  48. It accepts a mask (see definition below) which determines which sort of char-
  49. acters are returned. The mask types can be combined with a logical or to
  50. return multiple character types. If no key has been pressed, the function
  51. waits. Otherwise, the next key is retrieved and compared against the mask. If
  52. it matches the function returns true (see enum in KEYBOARD.HPP), and the
  53. ascii and extended codes are returned in key and scan. If the key doesn't
  54. match the function returns false and the values of key and scan are unchang-
  55. ed.
  56.  
  57. *****************************************************************************
  58.  
  59. void stuffbuffer(char key, extnd scan);
  60.  
  61. stuffbuffer() places the ascii and extended scancodes passed in key and scan
  62. into the keyboard buffer.
  63.  
  64. *****************************************************************************
  65.  
  66. void flushBuffer(char *buf);
  67.  
  68. flushBuffer() clears the keyboard buffer. if *buf != NULL then the flushed
  69. codes are stored there, else they are discarded.
  70.  
  71. *****************************************************************************
  72.  
  73. D. Constants and enumerated types
  74.  
  75. *****************************************************************************
  76.  
  77. enum boolean {false,true};
  78.  
  79. Used for return value in getfiltered key. May be used anywhere else where
  80. it's appropriate.
  81.  
  82. *****************************************************************************
  83.  
  84. enum extnd {F1=59,F2,F3,F4,F5,F6,F7,F8,F9,F10,
  85.             F11=133,F12,
  86.             S_F1=84,S_F2,S_F3,S_F4,S_F5,S_F6,S_F7,S_F8,S_F9,S_F10,
  87.             S_F11=135,S_F12,
  88.             C_F1=94,C_F2,C_F3,C_F4,C_F5,C_F6,C_F7,C_F8,C_F9,C_F10,
  89.             C_F11=137,C_F12,
  90.             A_F1=104,A_F2,A_F3,A_F4,A_F5,A_F6,A_F7,A_F8,A_F9,A_F10,
  91.             A_F11=139,A_F12,
  92.             S_TAB=15,
  93.             HOME=71,UP_ARR,PG_UP,LT_ARR=75,RT_ARR=77,END=79,DN_ARR,
  94.             PG_DN,INS,DEL,
  95.             C_PRTSC=114,C_LT_ARR,C_RT_ARR,C_END,C_PG_DN,C_HOME,
  96.             C_PG_UP=132, NO_EXT=0};
  97.  
  98. The extnd enumerated type provides constants used to refer to the extended
  99. scan codes returned by getkey() and getfilteredkey(). Both functions return
  100. extended codes as type extnd. Prefixes are: C_ control and key, A_ alt and
  101. key, and S_ shift and key.
  102.  
  103. *****************************************************************************
  104.  
  105.  mask types passed to getfilteredkey() to select keymask. Masks operate
  106.  as follows:
  107.               U_CASE   - returns only upper case characters
  108.               L_CASE   - returns only lower case characters
  109.               B_CASE   - returns characters of both cases
  110.               NUMBER   - returns only numbers
  111.               FUNCT    - returns only function keys
  112.               CURSOR   - returns only cursor positioning keys
  113.               PUNCT    - returns only punctuation marks
  114.               ESC      - returns only the escape key
  115.  
  116.  the masks can be combined with a logical OR in the call, for example:
  117.  
  118.  if(getfilteredkey(&s,&c,U_CASE|NUMBER|FUNCT))
  119.  
  120.  will return true if the key pressed was an upper case character, a
  121.  number, or a function key. If true, the key's ascii code and scan
  122.  value are in scan and key.
  123.  
  124.  const char UCASE = 0x1;
  125.  const char LCASE = 0x2;
  126.  const char BCASE = 0x4;
  127.  const char NUMBER = 0x8;
  128.  const char FUNCT  = 0x10;
  129.  const char CURSOR = 0x20;
  130.  const char PUNCT  = 0x40;
  131.  const char ESC   = 0x80;
  132.  
  133. *****************************************************************************
  134.  
  135. E. Support
  136.  
  137. Support for this tool will be provided as and where possible through mess-
  138. ages posted to 76605,2346 in the Game Design section (sec. 11) of the Gamers
  139. Forum on Compuserve. Sorry, no telephone support is possible.
  140.  
  141.  
  142.  
  143.  
  144.